<?php

class MenusController extends AppController
{
	var $name = "Menus";
	var $uses = array();

	function index()
	{	
	}
	
	function read($menuName)
	{
		uses('xml');
		$menu_sidebar =& new XML(PATH_FILES . "menu_$menuName.xml");
		
		$menu = array();
		
		foreach ($menu_sidebar->children[0]->children as $Node):
			 
			 //leemos los subitems
			$subitems = array();
			
			foreach ($Node->children as $nomId => $Nod):		
				$subitems[$nomId]['name']=$Nod->attributes['name'];
				$subitems[$nomId]['url']=$Nod->attributes['url'];
				$subitems[$nomId]['title']=$Nod->attributes['title'];
			endforeach;
			 
			 $menu[$Node->attributes['name']] = array
			 (
			 	'url'=> $Node->attributes['url'],
			 	'title'=> $Node->attributes['title'],
			 	'image'=> $Node->attributes['image'],
			 	'subitems'=> $subitems
			 );
		
		endforeach;
		
		return $menu;

	}
	
}

